package com.btex.app.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.widget.TextView;

import com.btex.app.R;
import com.btex.app.entity.OTCStateListInfo;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * @author zy zhangyi <zhangyi, 1104745049@QQ.com
 * @version v1.0
 * @project study1
 * @Description
 * @encoding UTF-8
 * @date 2018/8/17
 * @time 下午5:01
 * @修改记录 <pre>
 * 版本       修改人         修改时间         修改内容描述
 * --------------------------------------------------
 * <p>
 * --------------------------------------------------
 * </pre>
 */

public class OTCStateListAdapter extends BaseQuickAdapter<OTCStateListInfo.DataBean, BaseViewHolder> {
    private Context mContext;

    public OTCStateListAdapter(Context context) {
        super(R.layout.item_otc_state_list);

        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, OTCStateListInfo.DataBean item) {

        RecyclerView view = (RecyclerView) helper.getView(R.id.item_otc_state_list_recy);


        List<String> imgs = item.getImgs();
        int size = imgs.size();
        OTCItemListAdapter otcItemListAdapter = new OTCItemListAdapter(imgs, mContext);
        view.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
        view.setAdapter(otcItemListAdapter);


        TextView item_otc_state_list_content = (TextView) helper.getView(R.id.item_otc_state_list_content);
        if (!TextUtils.isEmpty(item.getContent())) {
            item_otc_state_list_content.setText(item.getContent());

        }

        TextView item_otc_state_list_time = (TextView) helper.getView(R.id.item_otc_state_list_time);

        if (!TextUtils.isEmpty(item.getCtime())) {
            item_otc_state_list_time.setText(item.getCtime());

        }

        TextView item_otc_state_list_name = (TextView) helper.getView(R.id.item_otc_state_list_name);

        int owner = item.getOwner();
        if (owner == 1) {
            item_otc_state_list_name.setText("我");
            item_otc_state_list_name.setTextColor(Color.parseColor("#f0a503"));

        } else if (owner == 3) {
            item_otc_state_list_name.setText("交易对方");
            item_otc_state_list_name.setTextColor(Color.parseColor("#2ea425"));
        } else {
            item_otc_state_list_name.setText("BTEX 客服");
            item_otc_state_list_name.setTextColor(Color.parseColor("#586faa"));
        }


    }

}
